function myPromise(fn) {
  let _self = this;
  _self.status = "pending";//默认状态
  _self.value = undefined;
  _self.reason = undefined;
  function resolve(value) {
    _self.status = "resolved"
    _self.value = value;
  }
  function reject(reason) {
    _self.status = "rejected"
    _self.reason = reason;
  }
  try {
    fn(resolve, reject);
  } catch (error) {
    reject(error);
  }
}

myPromise.prototype.then = function (onFulfilled, onRejected) {
  let _self = this;
  switch (_self.status) {
    case "resolved":
      onFulfilled(_self.value)
      break;
    case "rejected":
      onRejected(_self.reason)
      break;
    default:
  }

}


const person = {
  name: "Lydia Hallie",
  age: 21
}
// function* ddq (){
//   yield* Object.values(this) 
// }
person[Symbol.iterator] = function* () {
  yield* Object.values(this)
}
console.log([...person]); // ["Lydia Hallie", 21]
let arr = [1, 2, 3]
console.log(person[Symbol.iterator]);


function Car(name) {
  this.name = name
}
Car.prototype.getName = function () { return this.name }
console.log(Car);


function Test() {

}


console.log(Test == Test.prototype.constructor);


function add(num) {
  if (num <= 1) return num
  return add(num - 1) + add(num - 2)
}


console.log(add(8));